$(function () {
    let res = myAjax("/index", {}, 'get');
    console.log(res);
    setNewsData(res.newsDTOList);
    setProductData(res.productDTOList);
})


function setNewsData(data) {

}

function setProductData(data) {

    let html = '';
    for (let i = 0; i < data.length; i++) {
        html += '<div>\n' +
            '                        <div><img src="' + data[i].imgHref + '"></div>\n' +
            '                        <div class="font-title single-over" onclick="goToProductDetail(' + data[i].id + ')">' + data[i].name + '</div>\n' +
            '                        <div class="font-content single-over">\n' +
            '                            ' + data[i].content + '\n' +
            '                        </div>\n' +
            '                    </div>';
    }
    $("#product").html(html);
}

function goToProductDetail(id) {
    // console.log(id);
    sessionStorage.setItem("productId", id);
    //target:_black,_self,_top
    window.open("/html/product-detail.html");
}